import { defineStore } from "pinia"
import {ref} from 'vue'

export const useUserInfoStore = defineStore('userInfo', () => {
    const userInfo = ref<Record<string, any>>()
    const permissionList = ref<Array<string>>([])
    const roleList = ref<Array<string>>([])
    
    const setInfo = (newInfo: Record<string, any>, newPermissionList: Array<string>, newRoleList: Array<string> ) => {
        userInfo.value = newInfo
        permissionList.value = newPermissionList
        roleList.value = newRoleList
    }

    const removeInfo = () => {
        userInfo.value = {}
        permissionList.value = []
        roleList.value = []
    }

    return {userInfo, setInfo, removeInfo, permissionList, roleList}
},
{
    persist: true
}
)

